<?php
/**
 * @Author: liuhongbin
 * @Email: 514660094@qq.com
 * @Date: 2019-02-12 16:15:10
 * @Description:
 * @LastEditors: liuhongbin
 * @LastEditTime: xxx
 */

namespace app\common\model\platform;

use app\common\model\BaseModel;

/**
 * 小程序模型
 * @package app\common\model
 * User: liuhongbin
 * Date: 2021-05-25 14:16
 */
class PlatformWxapp extends BaseModel
{
    /**
     * 数据表主键
     * @var string
     */
    protected $pk = 'id';

    /**
     * 模型名称
     * @var string
     */
    protected $name = 'platform_wxapp';

    /**
     * 获取平台详情
     * @param $plaid
     * @return PlatformWxapp|array|mixed|\think\Model|null
     */
    public function getPlatformDetails($plaid)
    {
        $SettingModel = new PlatformSetting();
        $res = $this->where(['plaid' => $plaid])->find();
        $res['api_url'] = url("/h5/api/index", ['p' => $plaid], true, true)->build();
        $res['setting'] = array(
            'pay'      => $SettingModel->where(['key' => 'pay', 'plaid' => $plaid])->find(),
            'transfer' => $SettingModel->where(['key' => 'transfer', 'plaid' => $plaid])->find()
        );
        return $res;
    }
}
